﻿using System;
using System.Collections;
using System.Configuration;
using System.Web;
using System.Data;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace Baocao
{
	public partial class Master : System.Web.UI.MasterPage
	{
		protected void Page_Load(object sender, EventArgs e)
		{
            if (Request.Browser.IsMobileDevice == true)
            {
                Session["Mobie"] = "1";
            }
            else
                Session["Mobie"] = null;
			lblUser.Text = ((DataTable)Session["UserInfo"]).Rows[0]["UserName"].ToString();            
            if (((DataTable)Session["UserInfo"]).Rows[0]["ParentUser"] == DBNull.Value)
            {                
                lbThemMoi.Visible = true;
            }
            else
            {
                lbThemMoi.Visible = false;
            }
		}

		protected void lblLogout_Click(object sender, EventArgs e)
		{
			//remove all sessions to the application
			Session.Clear();
			Session.Abandon();

			//remove all cookies to the application
			HttpCookie aCookie;
			string cookieName;
			int limit = Request.Cookies.Count;
			for (int i = 0; i < limit; i++)
			{
				cookieName = Request.Cookies[i].Name;
				aCookie = new HttpCookie(cookieName);
				aCookie.Expires = DateTime.Now.AddDays(-1);
				Response.Cookies.Add(aCookie);
			}

			//redirection to Login page
			Response.Redirect("~\\Login.aspx");
		}

		public void ChangeTitle(string newTitle)
		{
			Page.Title = newTitle;
		}

		protected void lblUser_Click(object sender, EventArgs e)
		{
			Response.Redirect("~\\ChangeUserInfo.aspx");
		}
        protected void lblThemMoi_Click(object sender, EventArgs e)
		{
			Response.Redirect("~\\Register.aspx");
		}        
	}
}
